package com.ushio.gougouwangguo.utils.redis;

import com.ushio.gougouwangguo.entity.mysql.Resource;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Component
public class ResourceRedisUtils {

    @Autowired
    RedissonClient redissonClient;

    private final static String RESOURCE_RESOURCE = "resource";

    public List<Resource> getResource(){

        RMap<String, Resource> map = redissonClient.getMap(RESOURCE_RESOURCE);

        Collection<Resource> values = map.values();

        return new ArrayList<>(values);
    }
    public void delResource(){

        RMap<String, Resource> map = redissonClient.getMap(RESOURCE_RESOURCE);

        map.delete();
    }

}
